package org.dslmagic.data;

import java.util.Collection;
import java.util.Iterator;

public abstract class Group {

	public static Group from(Object target) {
		if (target instanceof Object[]) {
			Object[] array = (Object[]) target;
			return new ArrayGroup(array);
		}
		if (target instanceof Collection<?>) {
			Collection<?> coll = (Collection<?>) target;
			return new CollectionGroup(coll);
		}

		throw new RuntimeException("Expected array or collection!");
	}

	public abstract Iterator<?> iterator();

	public abstract Object value();

	public abstract Object[] toArray();
}
